package com.example.base.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;

import com.example.base.R;

public class WebViewActivity extends AppCompatActivity {
  private WebView webView;
  private ImageButton imageButton;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);
    initView();
    initListener();
    WebViewShow();
  }

  private void WebViewShow() {
    Intent intent = getIntent();
    String url = intent.getStringExtra("Url");
    webView.loadUrl(url);
    webView.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return false;
      }
    });
  }

  private void initListener() {
    imageButton.setOnClickListener(v -> finish());
  }

  private void initView() {
    imageButton = findViewById(R.id.image_web_back);
    webView = findViewById(R.id.webView_ques);
  }
}